﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DTO;
using BUS;
namespace QLCHHoaLan
{
    public partial class FrmThongKeBaoCao : Form
    {
        public FrmThongKeBaoCao()
        {
            InitializeComponent();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Menu main = new Menu();
            main.kq = 1;
            main.Show();
            this.Hide();
        }

        private void FrmThongKeBaoCao_Load(object sender, EventArgs e)
        {
            txtNgayTK.Text = DateTime.Now.ToShortDateString();
            dgvsoLuongBan.AutoGenerateColumns = false;
            dgvSoLuongNhap.AutoGenerateColumns = false;
            dgvSoLuongTon.AutoGenerateColumns = false;

        }
        private void btnThongKe_Click(object sender, EventArgs e)
        {
             ThongKeBUS tkBUS = new ThongKeBUS();
            ThongKeDTO Tk = new ThongKeDTO();
             Tk.ThoiGian = Convert.ToDateTime(txtNgayTK.Text);
            if (cbbLoaiThongKe.Text == "Thống Kê Chi Tiết")
            {
                 List<ThongKeDTO> list2 = new List<ThongKeDTO>();
                 List<ThongKeDTO> list3 = new List<ThongKeDTO>();
                 List<ThongKeDTO> list1 = new List<ThongKeDTO>();
                 list1 = tkBUS.LaySoLuongNhap_Ngay(Tk);
                 
                 list2 = tkBUS.LaySoLuongBan_Ngay(Tk);
                 list3 = tkBUS.LaySoLuongTonKho(Tk);
                 dgvSoLuongNhap.DataSource = list1;
                 dgvsoLuongBan.DataSource = list2;
                 dgvSoLuongTon.DataSource = list3;
              
            }
            txtSoDonHang.Text = tkBUS.LaySoLuongDonHang(Tk).ToString();
            txtTongThuNhap.Text = tkBUS.TinhTongThuNhap(Tk.ThoiGian).ToString();
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            txtNgayTK.Text = null;
            txtSoDonHang.Text = null;
            txtTongThuNhap.Text = null;          
        }
    }
}
